import java.awt.Graphics;
import java.awt.Point;

public class Creature
{
	private final static int EAST = 0, SOUTH = 1, WEST = 2, NORTH = 3;
	int i = 0; // graphic index for tileSheet
	int dir = EAST; // starting direction
	int x, y;

	// The constructor that only takes x,y and the graphic index
	public Creature(int c_x, int c_y, int c_i)
	{
		x = c_x;
		y = c_y;
		i = c_i;

	}

	// The constructor that additionally takes the object's starting direction.
	public Creature(int c_x, int c_y, int c_d, int c_i)
	{
		x = c_x;
		y = c_y;
		dir = c_d;
		i = c_i;

	}

	public void draw(Graphics g, TileSheet tiles)
	{
		// tiles.draw(g, x * tiles.tileSize.x, y * tiles.tileSize.y, (i + dir));
		tiles.draw(g, 6 * tiles.tileSize.x, 6 * tiles.tileSize.y, (i + dir));
		// This draws the object at x,y and uses the index + direction to
		// determine which tile to use. All object tiles should have all four
		// directions sequentially in the order N,E,S,W to make them consistent
		// with the way the program tracks directions.
	}

	public void move(Point p)
	{
		x = p.x;
		y = p.y;
	}

	public void turnLeft()
	{
		dir--;
		if (dir < EAST)
		{
			dir = NORTH;
		}
	}

	public void turnRight()
	{
		dir++;
		if (dir > NORTH)
		{
			dir = EAST;
		}
	}

	public Point moveForward()
	{
		Point p = new Point();

		switch ( dir )
		{
		case EAST:
			p.setLocation(x + 1, y + 0);
			break;
		case SOUTH:
			p.setLocation(x + 0, y + 1);
			break;
		case WEST:
			p.setLocation(x - 1, y + 0);
			break;
		case NORTH:
			p.setLocation(x + 0, y - 1);
			break;

		}
		return p;

	}

}
